<?php
/**
 * swoole内存表
 * Created by PhpStorm.
 * Author: 张志祥
 * QQ: 786811688
 * Phone: 13306281319
 * Date: 2017/5/1
 * Time: 8:05
 */

// 设置全局变量
$gp = new swoole_table(64);
$gp->column('val', swoole_table::TYPE_FLOAT);
$gp->create();

// 设置字符串型全局变量
$gpstr = new swoole_table(64);
$gpstr->column('val', swoole_table::TYPE_STRING, 1024);
$gpstr->create();

// 商品最新价格全局变量
$table_price = new swoole_table(32);
$table_price->column('price', swoole_table::TYPE_FLOAT); //最新价格
$table_price->create();

// 持仓订单表，最大持仓3万
$table = new swoole_table(32768);
$table->column('fd', swoole_table::TYPE_INT, 4);//客户端连接标识
$table->column('uid', swoole_table::TYPE_INT, 4);//用户id
$table->column('utel', swoole_table::TYPE_INT, 8);//用户手机号码
$table->column('jid', swoole_table::TYPE_INT, 4);//交易机构id
$table->column('code', swoole_table::TYPE_STRING, 10);//产品编码
$table->column('period', swoole_table::TYPE_STRING, 10);//购买期号
$table->column('buytime', swoole_table::TYPE_INT, 4);//买入时间
$table->column('otype', swoole_table::TYPE_INT, 1);//购买单双类型
$table->column('lots', swoole_table::TYPE_INT, 4);//购买手数
$table->column('omoney', swoole_table::TYPE_STRING, 10);//订单金额类型
$table->column('revenue', swoole_table::TYPE_INT, 4);//预计收益
$table->column('money', swoole_table::TYPE_INT, 4);//订单金额
$table->column('service_fee', swoole_table::TYPE_FLOAT);//手续费
$table->column('gift', swoole_table::TYPE_INT, 4);//赠金
$table->create();

// 平仓待处理队列，最大5k
$q_table = new swoole_table(8192);
$q_table->column('fd', swoole_table::TYPE_INT, 4);//客户端连接标识
$q_table->column('uid', swoole_table::TYPE_INT, 4);//用户id
$q_table->column('utel', swoole_table::TYPE_INT, 8);//用户手机号码
$q_table->column('jid', swoole_table::TYPE_INT, 4);//交易机构id
$q_table->column('code', swoole_table::TYPE_STRING, 10);//产品编码
$q_table->column('period', swoole_table::TYPE_STRING, 10);//购买期号
$q_table->column('buytime', swoole_table::TYPE_INT, 4);//买入时间
$q_table->column('otype', swoole_table::TYPE_INT, 1);//购买单双类型
$q_table->column('lots', swoole_table::TYPE_INT, 4);//购买手数
$q_table->column('omoney', swoole_table::TYPE_STRING, 10);//订单金额类型
$q_table->column('money', swoole_table::TYPE_INT, 4);//订单金额
$q_table->column('revenue', swoole_table::TYPE_INT, 4);//预计收益
$q_table->column('service_fee', swoole_table::TYPE_FLOAT);//手续费
$q_table->column('gift', swoole_table::TYPE_INT, 4);//赠金
$q_table->column('ssc_winningNumber', swoole_table::TYPE_STRING, 12);//赠金
$q_table->column('kl8_WinNumber', swoole_table::TYPE_STRING, 80);//赠金
$q_table->create();

// 平仓时遇到错误的订单信息表
$err_orders = new swoole_table(1024);
$err_orders->column('time', swoole_table::TYPE_INT, 4); // 平仓时间
$err_orders->column('sellprice', swoole_table::TYPE_FLOAT); // 平仓价格
$err_orders->column('err_num', swoole_table::TYPE_INT, 4); // 错误次数
$err_orders->create();

// 用户信息表，用户数量最大10万
$uinfo = new swoole_table(131072);
$uinfo->column('last_time', swoole_table::TYPE_INT, 4); // 最近操作时间
$uinfo->column('balance', swoole_table::TYPE_FLOAT); // 用户余额
$uinfo->column('all_money', swoole_table::TYPE_FLOAT); // 持仓订单总金额
$uinfo->column('all_position', swoole_table::TYPE_INT, 4); // 总持仓订单数量
$uinfo->column('order_lis', swoole_table::TYPE_STRING, 512); // 持仓订单列表
$uinfo->create();

